﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:apexControls="clr-namespace:Apex.Controls"
    xmlns:apexCommands="clr-namespace:Apex.Commands"
    xmlns:apexDesign="clr-namespace:Apex.Design">
    <Style TargetType="{x:Type apexControls:CrossButton}">
        <Style.Resources>
            <SolidColorBrush x:Key="TabItemCloseButtonNormalBackgroundBrush" Color="#00000000" />
            <SolidColorBrush x:Key="TabItemCloseButtonNormalBorderBrush" Color="#FFFFFFFF" />
            <SolidColorBrush x:Key="TabItemCloseButtonNormalForegroundBrush" Color="#FF8f949b" />

            <SolidColorBrush x:Key="TabItemCloseButtonHoverBackgroundBrush" Color="#FFc13535" />
            <SolidColorBrush x:Key="TabItemCloseButtonHoverForegroundBrush" Color="#FFf9ebeb" />

            <SolidColorBrush x:Key="TabItemCloseButtonPressedBackgroundBrush" Color="#FF431e20" />
            <SolidColorBrush x:Key="TabItemCloseButtonPressedBorderBrush" Color="#FF110033" />
            <SolidColorBrush x:Key="TabItemCloseButtonPressedForegroundBrush" Color="#FFf9ebeb" />
        </Style.Resources>
        <Setter Property="SnapsToDevicePixels" Value="false" />
        <!--    <Setter Property="Height" Value="16" />
        <Setter Property="Width" Value="16" /> -->
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type apexControls:CrossButton}">
                     <Grid Background="Transparent">
                        <Ellipse x:Name="backgroundEllipse" Fill="{TemplateBinding NormalBackgroundBrush}" />
                        
                         <!-- The Path below will render the button's X. -->
                        <Path x:Name="ButtonPath"
                              Margin="3"
                              Stroke="{TemplateBinding NormalCrossBrush}"
                              StrokeThickness="1.5"
                              StrokeStartLineCap="Square"
                              StrokeEndLineCap="Square"
                              Stretch="Uniform"
                              VerticalAlignment="Center"
                              HorizontalAlignment="Center">
                            <Path.Data>
                                <PathGeometry>
                                    <PathGeometry.Figures>
                                        <PathFigure StartPoint="0,0">
                                            <LineSegment Point="25,25"/>
                                        </PathFigure>
                                        <PathFigure StartPoint="0,25">
                                            <LineSegment Point="25,0"/>
                                        </PathFigure>
                                    </PathGeometry.Figures>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter 
                                TargetName="backgroundEllipse" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HoverBackgroundBrush}" />
                            <Setter 
                                TargetName="ButtonPath" Property="Stroke" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HoverCrossBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter 
                                TargetName="backgroundEllipse" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PressedBackgroundBrush}" />
                            <Setter 
                                TargetName="ButtonPath" Property="Stroke" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PressedCrossBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>